import com.alibaba.fastjson.JSONObject;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClientBuilder;
import org.apache.http.util.EntityUtils;

import java.io.IOException;

public class HttpClientDemo {
    public static void main(String[] args) throws IOException {


        CloseableHttpClient client = HttpClientBuilder.create().build();

        HttpPost post = new HttpPost("http://doitedu:8081/api/post/simwords");
        post.addHeader("Content-Type","application/json;utf-8");
        post.addHeader("Accept","application/json");


        JSONObject params = new JSONObject();
        params.put("origin","usb 移动固态");

        post.setEntity(new StringEntity(params.toJSONString(),"utf-8"));


        CloseableHttpResponse response = client.execute(post);

        HttpEntity entity = response.getEntity();
        String result = EntityUtils.toString(entity,"utf-8");

        System.out.println(result);

    }
}
